package com.example.deleguesapp;

import com.example.delegues.adapter.EleveAdapter;
import com.example.delegues.model.User;
import com.example.deleguesapp.manager.DataManager;


import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class MainActivity extends Activity implements OnItemClickListener {
	private ListView listEleves;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        listEleves = (ListView) findViewById(R.id.listEleves);
        listEleves.setAdapter(new EleveAdapter(this));
        listEleves.setOnItemClickListener(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

	public void onItemClick(AdapterView<?> adapter, View arg1, int position, long arg3) {
		// TODO Auto-generated method stub
		User eleve = (User) adapter.getItemAtPosition(position);
		Intent intent = new Intent(this,AppreciationActivity.class);
		DataManager.getInstance().setUser(eleve);
		startActivity(intent);
		Log.d("eleve", eleve.getName());
		
	}
}
